from fastapi import Request

from afast_core.core_plugins.pyee_event import EventEmitterPluginClient, NamedEventEmitter


def get_pyee_events_plugin_client_producer(request: Request) -> EventEmitterPluginClient:
    """
    返回事件处理的客户端对象
    :param request: current request.
    :return: pyee_events producer from the core_app.
    """
    return request.app.pyee_events_plugin_client


def get_pyee_events_producer(request: Request) -> NamedEventEmitter:
    """
    返回事件处理的客户端内部的原始的事件对象
    :param request: current request.
    :return: pyee_events producer from the core_app.
    """
    return request.app.state.pyee_events
